#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        int maxSum = 0; 
        for (int i = 1; i < s.size(); i++) {
            string s1 = s.substr(0, i); 
            string s2 = s.substr(i);
            int a1 = stoi(s1);
            int a2 = stoi(s2);
            maxSum = max(maxSum, a1 + a2);
        }
        cout << maxSum << endl;
    }
    return 0;
}